package com.mugu.ipclient;

import java.io.UnsupportedEncodingException;

/*
 ## Refresh packet
 # +--------------------+---------------------+--------------+--------------+-----------+
 # | (2) Banner(0x2382) | (1) Command         | (8) Key      | (8) Flow     | (8) Money |
 # | (4) Len1           | (Len1) Str_1/userid | (4) Len2     | (Len2) Str_2 | (4) Len3  |
 # | (Len3) Msg         | (4) Len4            | (Len4) Str_4 |              |           |
 # +--------------------+---------------------+--------------+--------------+-----------+
 */
public class RefreshPacketModel {

	private final short banner = 0x2382;
	private byte command;
	private long key;
	private double flow;
	private double money;
	private int len1;
	private String str1;
	private int len2;
	private String str2;
	private int len3;
	private String msg;
	private int len4;
	private String str4;

	public RefreshPacketModel() {

	}

	public RefreshPacketModel(byte command, long key, double flow,
			double money, String str1, String str2, String msg, String str4) {
		this.command = command;
		this.key = key;
		this.flow = flow;
		this.money = money;
		this.str1 = str1;
		this.str2 = str2;
		this.msg = msg;
		this.str4 = str4;
		try {
			this.len1 = str1.getBytes("gbk").length;
			this.len2 = str2.getBytes("gbk").length;
			this.len3 = msg.getBytes("gbk").length;
			this.len4 = str4.getBytes("gbk").length;
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}

	public byte getCommand() {
		return command;
	}

	public void setCommand(byte command) {
		this.command = command;
	}

	public long getKey() {
		return key;
	}

	public void setKey(long key) {
		this.key = key;
	}

	public double getFlow() {
		return flow;
	}

	public void setFlow(double flow) {
		this.flow = flow;
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}

	public int getLen1() {
		return len1;
	}

	public void setLen1(int len1) {
		this.len1 = len1;
	}

	public String getStr1() {
		return str1;
	}

	public void setStr1(String str1) {
		this.str1 = str1;
	}

	public int getLen2() {
		return len2;
	}

	public void setLen2(int len2) {
		this.len2 = len2;
	}

	public String getStr2() {
		return str2;
	}

	public void setStr2(String str2) {
		this.str2 = str2;
	}

	public int getLen3() {
		return len3;
	}

	public void setLen3(int len3) {
		this.len3 = len3;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getLen4() {
		return len4;
	}

	public void setLen4(int len4) {
		this.len4 = len4;
	}

	public String getStr4() {
		return str4;
	}

	public void setStr4(String str4) {
		this.str4 = str4;
	}

	public short getBanner() {
		return banner;
	}

	@Override
	public String toString() {
		return "RefreshPacketModel [banner=0x" + Integer.toHexString(banner)
				+ ", command=ox" + Integer.toHexString(command) + ", key="
				+ key + ", flow=" + flow + ", money=" + money + ", len1="
				+ len1 + ", str1=" + str1 + ", len2=" + len2 + ", str2=" + str2
				+ ", len3=" + len3 + ", msg=" + msg + ", len4=" + len4
				+ ", str4=" + str4 + "]";
	}
}
